import baseRequest from "@/axios/baseRequest"

export default {
  getList(params) {
    let str = ''
    for (let key in params) {
      if (params[key]) {
        str += [key] + '=' + params[key] + '&'
      }
    }
    return new Promise((resolve, reject) => {
      baseRequest.get("/bigdata-pv-backend/diagtask/pageDiagTaskList?" + str).then(data => {
        resolve(data)
      }).catch(e => {
        reject(e)
      })
    })
  },
  getCompanyList(params) {
    return new Promise((resolve, reject) => {
      baseRequest.get("/bigdata-pv-backend/diagtask/getCompanyList").then(data => {
        resolve(data)
      }).catch(e => {
        reject(e)
      })
    })
  },
  getDiagTaskList(params) {
    return new Promise((resolve, reject) => {
      baseRequest.get("/bigdata-pv-backend/diagtask/getDiagTaskList?companyCode=" + params.companyCode + '&stationCode=' + params.stationCode + '&inspectTaskCode=' + params.inspectTaskCode).then(data => {
        resolve(data)
      }).catch(e => {
        reject(e)
      })
    })
  },
  uploadInspectTaskInfo(params) {
    return new Promise((resolve, reject) => {
      baseRequest.post("/bigdata-pv-backend/inspecttaskinfo/uploadInspectTaskInfo", params).then(data => {
        resolve(data)
      }).catch(e => {
        reject(e)
      })
    })
  },
  getReport(params) {
    return new Promise((resolve, reject) => {
      baseRequest.get("/bigdata-pv-backend/diagtask/getDiagReportDetails?diagTaskCode=" + params.diagTaskCode + '&diagModelCode=' + params.diagModelCode).then(data => {
        resolve(data)
      }).catch(e => {
        reject(e)
      })
    })
  },
  insertInspectTaskInfo(params) {
    return new Promise((resolve, reject) => {
      baseRequest.post("/bigdata-pv-backend/inspecttaskinfo/insertInspectTaskInfo", params).then(data => {
        resolve(data)
      }).catch(e => {
        reject(e)
      })
    })
  },
  updateInspectTaskInfo(params) {
    return new Promise((resolve, reject) => {
      baseRequest.put("/bigdata-pv-backend/inspecttaskinfo/updateInspectTaskInfo", params).then(data => {
        resolve(data)
      }).catch(e => {
        reject(e)
      })
    })
  }
}
